home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AGA Toolkit '97
/
The AGA Toolkit '97.iso
/
workbench
/
blanker
/
multiblank
/
developers
/
example.e
< prev
Wrap
Text File
|
1996-09-07
|
3KB
|
130 lines
MODULE '*mblank',
'exec/ports', 'exec/nodes', 'dos/dos', 'utility/tagitem',
'intuition/intuition', 'intuition/screens'
ENUM ER_NONE, ER_MSGPORT
DEF conport = NIL:PTR TO mp, consig
DEF scr = NIL:PTR TO screen
OBJECT modprefs -> alter contents for your mod.
dummy
ENDOBJECT
PROC main () HANDLE
DEF msg:PTR TO msgheader, done = FALSE, type, sig, success
IF ((conport := CreateMsgPort ()) = NIL) THEN
Raise (ER_MSGPORT)
conport.ln.name := 'MBlank'
conport.ln.pri := 5
AddPort (conport)
consig := Shl (1, conport.sigbit)
REPEAT
sig := Wait (consig OR SIGBREAKF_CTRL_C)
IF (sig AND consig)
WHILE (msg := GetMsg (conport))
type := msg.type
SELECT type
CASE MBMT_INIT
msg::initmsg.flags := IMF_INFO
msg::initmsg.success := TRUE
ReplyMsg (msg)
CASE MBMT_BLANK
success := startmod ()
msg::blankmsg.success := success
ReplyMsg (msg)
IF (success)
REPEAT
UNTIL (sig := Wait (consig OR SIGBREAKF_CTRL_C))
ENDIF
CASE MBMT_CLEAR
clearmod ()
ReplyMsg (msg)
CASE MBMT_CONFIG
msg::infomsg.success := configmod (msg::infomsg.window)
ReplyMsg (msg)
CASE MBMT_INFO
msg::infomsg.success := modinfo (msg::infomsg.window)
ReplyMsg (msg)
CASE MBMT_QUIT
quitmod ()
done := TRUE
ReplyMsg (msg)
ENDSELECT
ENDWHILE
ENDIF
IF (sig AND SIGBREAKF_CTRL_C)
done := TRUE
ENDIF
UNTIL done
EXCEPT DO
IF (conport)
RemPort (conport)
clearport (conport, TRUE)
DeleteMsgPort (conport)
ENDIF
ENDPROC
PROC startmod ()
IF (scr := OpenScreenTagList (NIL, [SA_DISPLAYID, $0,
SA_DEPTH, 1,
SA_QUIET, TRUE,
SA_COLORS, [0, 0, 0, 0,
1, 15, 15, 15,
-1, 0, 0, 0]:colorspec,
TAG_DONE]))
RETURN TRUE
ENDIF
ENDPROC FALSE
PROC clearmod ()
IF (scr) THEN CloseScreen (scr); scr := NIL -> Unset variables
ENDPROC
PROC modinfo (win:PTR TO window)
ezrequester (win, 'Module Information', 'Example Module © 1995 S. Clayton', 'Okay')
ENDPROC TRUE -> success
PROC configmod (win:PTR TO window)
ENDPROC FALSE -> mod doesn't support configuration
PROC ezrequester (win, title, body, gads)
ENDPROC EasyRequestArgs (win, [20, 0, title, body, gads], NIL, NIL)
PROC saveprefs (prefs)
DEF file, len = -1, prefsname[107]:STRING
IF (GetProgramName (prefsname, 100))
SetStr (prefsname, StrLen (prefsname)); StrAdd (prefsname, '.prefs')
IF (file := Open (prefsname, NEWFILE))
len := Write (file, prefs, SIZEOF modprefs)
Close (file)
ENDIF
ENDIF
ENDPROC len
PROC loadprefs (prefs)
DEF file, len = -1, prefsname[107]:STRING
IF (GetProgramName (prefsname, 100))
SetStr (prefsname, StrLen (prefsname)); StrAdd (prefsname, '.prefs')
IF (file := Open (prefsname, OLDFILE))
len := Read (file, prefs, SIZEOF modprefs)
Close (file)
ENDIF
ENDIF
ENDPROC len
PROC clearport (port, reply)
DEF msg
WHILE (msg := GetMsg (port))
IF (reply) THEN ReplyMsg (msg)
ENDWHILE
ENDPROC